#include <bits/stdc++.h>
using namespace std;
char mapp[101][101];
int ans[101][101];
int di[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dj[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> mapp[i][j];
    }
  }

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (mapp[i][j] == '.') {
        int total = 0;
        for (int k = 0; k < 8; k++) {
          int ni = i + di[k];
          int nj = j + dj[k];
          if (mapp[ni][nj] == '*') {
            total++;
          }
        }
        ans[i][j] = total;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (mapp[i][j] == '*') {
        cout << "*";
      } else {
        cout << ans[i][j];
      }
    }
    cout << endl;
  }

  return 0;
}